# -*- encoding: utf-8 -*-
from django.shortcuts import render_to_response
from django.shortcuts import redirect
from django.http import HttpResponse
from django.http import Http404
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth import logout
from django.core import serializers
from idit.dit.models import Dit
from django.template import RequestContext
from idit import settings

def home_timeline(req):
    if req.GET['until_id'] :
        until_id = req.GET['until_id']
        dits = Dit.objects.exclude(id__lt=until_id)[:settings.PER_PAGE_DIT_COUNT]
    else :
        dits = Dit.objects.all()[:settings.PER_PAGE_DIT_COUNT]
    json_serializer = serializers.get_serializer("json")()
    json_serializer.serialize(dits, ensure_ascii=False, stream=response)
    
